project(ProductTest)
cmake_minimum_required(VERSION 3.5.1)
set(CMAKE_SYSTEM_NAME Linux)
add_definitions("-Wall -Os -fno-strict-aliasing")

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(IpcCodePath ${PROJECT_SOURCE_DIR}/../IPC_Code)
set(ChipSdkPath ${PROJECT_SOURCE_DIR}/../IPC_Code/ChipSdk)

include(${IpcCodePath}/Cmake/CmakeFunction.cmake)

include_directories(include)
include_directories(ProductTestMain)
include_directories(ProductTestMain/ProductTestMedia)
include_directories(ProductTestCommon)
include_directories(ProductTestUartCommon)
include_directories(${IpcCodePath}/ChipSdk)
include_directories(${IpcCodePath}/ChipSdk/${CHIP_TYPE})
include_directories(${IpcCodePath}/ChipSdk/${CHIP_TYPE}/media)
include_directories(${IpcCodePath}/ChipSdk/${CHIP_TYPE}/include)
include_directories(${IpcCodePath}/OpenSourceCode/OSCCJSON)
include_directories(${IpcCodePath}/OpenSourceCode/OSCIniConfig)
include_directories(${IpcCodePath}/OpenSourceCode/OSCBase64)
include_directories(${IpcCodePath}/OpenSourceCode/OSCAes)

Cmake_include_dir(${IpcCodePath}/InCommon)
include_directories(${IpcCodePath}/Peripheral/InPerUart)
include_directories(${IpcCodePath}/InSdk/InSdkUcheck)
include_directories(${IpcCodePath}/InSdk/InSdkRingBuffer)
include_directories(${IpcCodePath}/InSdk/InSdkTcpSystem)
include_directories(${IpcCodePath}/InSdk/InSdkG711Code)

link_directories(lib/${CHIP_TYPE})
link_directories(${IpcCodePath}/ChipSdk/${CHIP_TYPE}/libs)
link_directories(${IpcCodePath}/InSdk/libs/${CHIP_TYPE})

include(${IpcCodePath}/ProDefine/CMakeLists.txt)

if(IngenicT41)
    include_directories(${ChipSdkPath}/${CHIP_TYPE}/OsdInfo)
endif()

aux_source_directory(ProductTestMain src_TestMain)
aux_source_directory(ProductTestMain/ProductTestMedia src_TestMedia)
aux_source_directory(${ChipSdkPath}/${CHIP_TYPE}/media src_MediaSdk)

if(CMAKE_SUPPORT_STEEP_ENGINE)
    Cmake_add_include_cache(${ChipSdkPath}/PwmCode)
    include_directories(${ChipSdkPath}/PwmCode)
    aux_source_directory(${ChipSdkPath}/PwmCode/${CmakePwmCodeMode} src_ChipPwm)
    set(src_MediaSdk ${src_MediaSdk} ${src_ChipPwm})
endif()

set(src_ComMedia ${IpcCodePath}/ChipSdk/SdkMediaCommon.c)
set(src_UartInit ${IpcCodePath}/Peripheral/InPerUart/InPerUartInit.c)
set(src_InSdk ${src_InSdk} ${IpcCodePath}/InSdk/InSdkRingBuffer/InSdkRingBuffer.c)
set(src_InSdk ${src_InSdk} ${IpcCodePath}/InSdk/InSdkTcpSystem/InSdkTcpSystemClient.c)
set(src_InSdk ${src_InSdk} ${IpcCodePath}/InSdk/InSdkG711Code/InSdkG711Code.c)
set(src_ChipSdk ${src_ComMedia} ${src_TestMedia} ${src_MediaSdk} ${src_InSdk})

aux_source_directory(ProductTestCommon src_TestCom)
aux_source_directory(ProductTestUartCommon src_Uart)
aux_source_directory(${IpcCodePath}/ChipSdk/${CmakeGpioCtrlMode} src_Gpio)
aux_source_directory(${IpcCodePath}/OpenSourceCode/OSCCJSON src_OscJson)
aux_source_directory(${IpcCodePath}/OpenSourceCode/OSCIniConfig src_OscIni)
set(src_OSC ${src_OscJson} ${src_OscIni})

aux_source_directory(${IpcCodePath}/InCommon/InComFileOperation src_File)
aux_source_directory(${IpcCodePath}/InCommon/InComDevInfo src_DevInfo)
aux_source_directory(${IpcCodePath}/InCommon/InComTimer src_Timer)
aux_source_directory(${IpcCodePath}/InCommon/InComCheckNetStatus src_CheckNet)
aux_source_directory(${IpcCodePath}/InCommon/InComIniConfig src_ComIni)
aux_source_directory(${IpcCodePath}/InCommon/InComSpkCtrl src_SpkCtrl)
aux_source_directory(${IpcCodePath}/InCommon/InComStringHandling src_StrHandle)
set(src_InCom ${src_File} ${src_DevInfo} ${src_Timer} ${src_CheckNet} ${src_ComIni} ${src_SpkCtrl} ${src_StrHandle})

if(CMAKE_SUPPORT_STEEP_ENGINE)
    include_directories(${IpcCodePath}/ChipSdk/PwmCode)
    aux_source_directory(${IpcCodePath}/ChipSdk/PwmCode/${CmakePwmCodeMode} src_Pwm)
endif()

if(CMAKE_SUPPORT_STEP_MOTOR)
    include_directories(${IpcCodePath}/ChipSdk/PtzMotor)
    aux_source_directory(${IpcCodePath}/ChipSdk/PtzMotor/${CmakePtzMotorMode} src_Motor)
    include_directories(${IpcCodePath}/Peripheral/InPerSteppingMotor)
    aux_source_directory(${IpcCodePath}/Peripheral/InPerSteppingMotor src_StepMotor)
endif()

if(CMAKE_SUPPORT_STEEP_ENGINE)
    include_directories(${IpcCodePath}/Peripheral/InPerSteeringEngine)
    aux_source_directory(${IpcCodePath}/Peripheral/InPerSteeringEngine src_StepEngine)
endif()

aux_source_directory(ProductionBurnUid src_BurnUid)
add_executable(burn_uid ${src_BurnUid} ${src_File} ${src_DevInfo} ${src_StrHandle} ${src_OSC})
target_link_libraries(burn_uid m pthread)

add_subdirectory(ProductTestMain/ProductTestMedia)

if(CMAKE_SUPPORT_AB6012BX)
    set(src_SdkLib ${src_SdkLib} nimble_linux)
endif()

add_executable(hardware_test ${src_TestMain} ${src_ChipSdk} ${src_TestCom} ${src_Uart} ${src_Gpio} ${src_OSC} ${src_InCom} ${src_UartInit} ${src_Pwm} ${src_Motor} ${src_StepMotor} ${src_StepEngine})
target_link_libraries(hardware_test dl pthread m rt ${ChipSdk_cache_lib} ${src_SdkLib})
